package com.zzw.common.result;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.Map;


/**
 * @author zzw
 * @date 2023/5/9 16:40
 */
@Data
@Accessors(chain = true) //可以进行链式操作
public class R {
    private String code;
    private String msg;
    private Map<String, Object> data;

    public static R ok(){
        R r = new R();
        r.setCode("200");
        r.setMsg("成功");
        return r;
    }

    public static R fail(){
        R r = new R();
        r.setCode("201");
        r.setMsg("失败");
        return r;
    }

    public  R data(String key,Object value){
        this.data.put(key,value);
        return this;
    }


    public static void main(String[] args) {
        HashMap<String, Object> map = new HashMap<>();
        R r = R.ok().setData(map);
    }
}
